<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{$naire.name}-{$parent}-{$children}</title>
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css" media="all">
</head>
<body>
<table class="table2excel layui-table"  border="1" data-name="{$naire.name}-{$parent}-{$children}" >
    <colgroup>
        <col width="150">
        <col width="150">
        <col>
    </colgroup>
    <thead>
    <tr>
        <th style="text-align: center;" colspan="{:count($base,COUNT_RECURSIVE)}">{$naire.name}-{$parent}-{$children}</th>
    </tr>
        <tr>
            {foreach $base as $t}
            <?php if($t['type']=='table')
                { $count=count($t['answer'],COUNT_RECURSIVE)-count($t['answer']);}
                else{
                    $count=count($t['answer'],COUNT_RECURSIVE);
                }
            ;?>
            <th style="text-align: center;" colspan="{$count}">{$t.name}</th>
            {/foreach}
        </tr>
        <tr>
            {foreach $base as $t}
                {foreach $t.answer as $key=>$value}
                <th style="text-align: center;" {if is_array($value)}colspan={:count($value)}{/if}>{$key}</th>
                {/foreach}
            {/foreach}
        </tr>
        <tr>
        {foreach $base as $t}
        {foreach $t.answer as $key=>$value}
            {if is_array($value)}
            {foreach $value as $k=>$v}
            <?php list($key,$value)=explode(',',$k);?>
                <th style="text-align: center;">{$key}</th>
            {/foreach}
            {else/}
                <th></th>
            {/if}
        {/foreach}
        {/foreach}
        </tr>
    </thead>
    <tbody>
        {foreach $group as $g}
            <tr>
                {foreach $g as $mk=> $m}
                {foreach $m.answer as $key=>$value}
                    {if(is_array($value))}
                        {foreach $value as $aa=>$bb}
                            <td>{$bb?$bb:''}</td>
                        {/foreach}
                    {else/}
                        <td>{$value?$value:''}</td>
                    {/if}
                {/foreach}
                {/foreach}
            </tr>
        {/foreach}
    </tbody>
</table>
<div style="text-align: left">
    <select id="redirect">
        <option data-url="{:url('admin/questionnaire/childrenshow',['id'=>$id,'parent'=>$parent,'children'=>$children])}">显示普通统计</option>
        <option data-url="{:url('admin/questionnaire/juzhengshow',['id'=>$id,'parent'=>$parent,'children'=>$children])}">只显示矩阵统计</option>
    </select>
</div>
<div style="text-align: right"><button id="excel" type="button">下载excel表格</button></div>
</body>
<script src="__STATIC__/js/table2excel/jquery.2.2.4.js"></script>
<script src="__STATIC__/js/table2excel/jquery.table2excel.min.js"></script>
<script src="__STATIC__/js/table2excel/down.js?id=2"></script>
<script>
    $('#redirect').change(function(){
        var _self=$(this);
        var selected=_self.find('option:selected');
        location.href=selected.data('url');
    })
</script>
</html>